import { Entity, Column, PrimaryGeneratedColumn, UpdateDateColumn, ManyToOne, JoinColumn, OneToMany } from 'typeorm';
import { ApiProperty} from '@nestjs/swagger';
import {
  IsOptional,
  IsString,
  MaxLength,
  MinLength,
  IsNotEmpty,
  IsEmail,
  IsPhoneNumber,
  IsDate,
  ValidateNested
} from "class-validator";
import { Goods } from './goods.entity';
import { Attribute } from './attribute.entity';
import { GoodsSpecification } from './goods_specification.entity';

@Entity()
export class Specification {
  @PrimaryGeneratedColumn()
  id: number;

  @IsOptional()
  @ApiProperty()
  @Column({type: 'varchar', length: 60, nullable: false})
  name: string;

  @IsOptional()
  @ApiProperty()
  @Column({type: 'tinyint', nullable: false})
  sort_order: number;

  @OneToMany(type => GoodsSpecification, goodsSpecification => goodsSpecification.specification)
  goodsSpecification: GoodsSpecification[]
}
